home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
026a
/
fifo.zip
/
README.TXT
< prev
next >
Wrap
Text File
|
1991-03-04
|
3KB
|
55 lines
This is a procedure (trangain) which computes the realized gain for an
investment account using "First In - First Out" (FIFO). When units
(or shares) are sold, there is a capital gain (or loss) on the sale. FIFO
uses the first shares purchased to compute the gain on the first sale. The
next sale uses the earliest purchased remaining un-sold shares to compute
the gain for that sale and so on. For example:
DATE SHARES AMOUNT
2-2-89 300 750.00 Purchase 300 shares for $750.00
3-4-89 150 412.50 Purchase 150 shares for $412.50
9-9-89 -200 -600.00 Sell 200 shares for $600.00
The gain computed on FIFO uses the 300 shares purchased on 2-2-89 at a cost
per share of $2.50 (750 / 300). The cost of the 200 shares sold on 9-9-89
was $500.00 (200 x 2.50). The gain on the 9-9-89 sale is $100.00 (600-500).
There are 100 shares of 2-2-89 purchase unsold.
12-12-89 -200 -450.00 Sell 200 shares for $450.00
The gain on this sale uses the remaining 100 unsold shares of the 2-2-89
purchase and 100 shares of the 3-4-89 purchase to compute the cost.
The cost is (100 x 2.50) + (100 x 412.50/150) = $525.00. The gain is thus
600.00-525.00 or $75.00.
The process is repeated for all sales to compute the gain for each sale.
This program does these tedious calculation for you. The procedure trangain
is called with 3 parameters.
macct = The account number of the investment to be analyzed
s_gain = The total gain for the account..returned to calling program
long = Is the account long. Long means you own the shares
that are being sold, short (not long) means you are selling
shares you don't own.
The database file, transact.dbf has a minimum of 5 fields:
DATE Date of the transaction
ACCT Account number (Charc) assingned to the investment
UNITS Number of units (or shares) bought or sold in the transaction
AMOUNT $ amount of the purchase (+) or sale (-)
GAIN $ amount of the gain realized on the transaction. This is
computed by the procedure trangain.
The database file is index on acct+DTOS(date) to order the transactions
in chronological order by account. I have included one account as an
example. It happens to be Fidelity Magellan Mutual Fund.
The way I use this procedure is every time I sell shares of an account,
I first REPLACE date,acct,units and amount into transact.dbf. If the units
are less than 0, (a sale), I then call trangain to compute and enter the
gain into that record.
Enjoy....Peare